<?php
class PlantPutSoilAction extends SzAbstractAction
{
    protected $paramTypes = array(
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_ARRAY,
        SzAbstractAction::TYPE_ARRAY,
        SzAbstractAction::TYPE_INT,
        SzAbstractAction::TYPE_INT
    );

    /**
     * Put a soil on ground.
     *
     * @param int $userId
     * @param int $itemDefId
     * @param array $gridIds
     * @param array $blockIds
     * @param int $orient
     * @param int $reqTime
     * @return SzResponse
     */
    public function execute($userId, $itemDefId, $gridIds, $blockIds, $orient, $reqTime)
    {
        GameService::get()->validateMultiRequestTimeDelta($userId, $reqTime);
        if (!GameService::get()->verifySysUnlock($userId, GameConst::FUNC_BUILDING_UPGRADE)) {
            return $this->buildResponse(false);
        }
        /**
         * @var GroundVo $ground
         * @var BuildingVo $building
         */
        list($ground, $building) = PlantService::get()->putSoil($userId, $itemDefId, $gridIds, $blockIds, $orient, $reqTime);
        return $this->buildResponse(array(
            'ground' => $ground->toArray(),
            'building' => $building->toArray()
        ));
    }
}